/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.service.dishes;
import com.alibaba.fastjson.JSONObject;
import com.qinyeit.serviceapp.entity.enums.DishesType;
import com.qinyetech.springstage.core.entity.search.Searchable;
import com.qinyetech.springstage.core.lang.QyMap;
import com.qinyetech.springstage.core.service.IBaseService;
import com.qinyeit.serviceapp.entity.Dishes;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.Map;

/** 
 * ClassName: DishesService <br/> 
 * Function: 菜品业务功能 <br/> 
 * date: 2018-11-23 11:45:37 <br/> 
 * 
 * @author liuwenjin
 * @version 1.0
 * @since JDK 1.8
 */
public interface DishesService extends IBaseService<Dishes, Long>{

    /**
     * 保存菜品
     * @param data
     *   dishes:{category:1} 菜品信息
     *   specs:[{specId:1,specName:xx,price:5,vipPrice:5,def:true}] -- 多规格
     *   marks:[{makeId:1,name:做法名称,makeCategoryId:2,makeCategoryName:做法类别,priceupType:加价类型,val:加价值}]  -- 多做法
     *   feeds:[{categoryId:加料类别,categoryName:类别名称,feedId:加料id,name:名称,price:价格}] -- 多加料
     *
     *   stockForm:{} 库存数据信息
     *   purchase:[] 多采购规格
     *
     *   return   material_id
     *            category_id,
     *            flag:是否保存原料 和 类别关系
     *
     */
    QyMap saveData(JSONObject data, Long merchantGroupId);

    /**
     * 保存原料中原料类别关系
     * @param categoryId
     * @param materialId
     */
    void saveMaterialForCategory(Long categoryId, Long materialId);

    /**
     * 获取菜品
     * @param merchantGroupId
     * @param storeId
     * @param categoryId
     * @param name
     * @return
     */
    Page<Map<String,Object>> getDishesData(Long merchantGroupId, Long storeId, Long categoryId, String name, Searchable searchable);

    /**
     * 保存套餐
     * @param data
     *  packages:{}
     *  selectDishes:[
     *      {
     *        name:"" 套餐组id
     *        total：总数量
     *        count：可选
     *        hasRepeat：是否重复
     *         details:[{
     *          def:true,
     *          name:xxx
     *          dishesId:123
     *          specName:xxx 规格名
     *          specId:111 //规格id
     *          alternative:false 是否备选
     *          count:菜品数量
     *          price：价格
     *          diff：00 差价
     *         }]
     *       }
     *
     * ] 菜品
     *
     * @param merchantGroupId
     */
    void savePackageData(JSONObject data,Long merchantGroupId);


    /**
     * 套餐明细
     * @param dishes
     * @return
     */
    List<Map<String,Object>> getPackDetails(Dishes dishes);

    /**
     * 删除套餐明细
     * @param id
     */
    void deletedPackageDetails(Long id);

    /**
     * 删除菜品相关的成本卡 和 成本卡明细
     * @param id
     */
    void deletedMaterialCostDetails(Long id);

    /**
     * 获取商品下一个编号
     * @param type
     * @param def
     * @return
     */
    public String getNextNo(DishesType type, String def,Long merchantGroupId);

    /**
     * 物理删除单店菜品信息
     * @param dishes
     */
    void deleteBranchDishesData(Dishes dishes);

    /**
     * 获取菜品包含的单店信息
     * 删除商品的时候自动删除单店的信息  提示 哪些门店有，都删除
     * @param
     * @param id
     * @return
     */
    List<Map<String,Object>> getDishesBranchs(Long id);

    /**
     * 删除单店的菜品信息  true 可以删除 单店接口删除 false 已使用，不能删除
     * @param uuid
     * @return
     */
    boolean deleteBranchDishesData(String uuid);

    /**
     * 保存某菜品库的商品信息
     * @param storeId 商品库id
     * @param merchantGroupId
     */
    void saveStoreTestInfos(Long storeId, Long merchantGroupId);

    /**
     * 验证code 条码唯一性
     * @param storeId 商品库id
     * @param code 条码 ["51515","65855"]
     * @param merchantGroupId
     */
    boolean verifyCode(Long storeId, String code, Long merchantGroupId,Long dishesId);
}